package com.jsy.testlock.lockimpl.redis;

import com.jsy.testlock.entity.MyInteger;
import com.jsy.testlock.lockimpl.FakeLock;
import org.redisson.Redisson;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author: SongyangJi
 * @description:
 * @since: 2021/11/29
 */
public class TestRedissonLock {


    public static RedissonClient initClient() {
        Config config = new Config();
        config.useSingleServer().setAddress("redis://127.0.0.1:6379");
        return Redisson.create(config);
    }


    public static void main(String[] args) {
//        MyInteger.testLock(new FakeLock());
//        MyInteger.testLock(new ReentrantLock());
//        MyInteger.testLock(initClient().getLock("lock1"));
        MyInteger.testLock(MyRedisLock.getLock("lock2"));
    }

}
